<?php

/**
 * cards actions.
 *
 * @package    essayLibrary
 * @subpackage cards
 * @author     Your name here
 * @version    SVN: $Id: actions.class.php 9301 2008-05-27 01:08:46Z dwhittle $
 */
class cardsActions extends sfGraduaActions
{
 /**
  * Executes index action
  *
  * @param sfRequest $request A request object
  */
  public function executeIndex($request)
  {
    $this->forward('default', 'module');
  }
  
  public function executeShowPrintCardsFilter($request) {
    $treeObject = Doctrine::getTable('DevTask')->getTree();
    $tree = $treeObject->fetchTree();
    $nodes = array();
    $item = array();
    foreach ($tree as $node) {
      $item['level'] = $node['level'];
      $item['name'] = $node['name'];
      $item['id']   = $node['id'];
      $nodes[] = $item;
    }
    sfLoader::loadHelpers(array('Partial','Php2Js'));
    return $this->showJsCall(
      JsCall::build()
        ->displayDialog(
          partial2Js( 'cards/filter' , array('nodes'=>$nodes), false )
        )
        ->addPHPParam('width','auto')
        ->addPHPParam('modal',true)
    );
  }
  
  public function executeViewPrintCards() {
    $parentTaskId = $this->getRequestParameter('parentTaskId');
    $task = Doctrine::getTable('DevTask')->find($parentTaskId);
    $descendants = $task->getNode()->getDescendants();
    $this->tree = $descendants;
    $this->setLayout('print');
  }
}
